package com.demo.dao;

import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import com.demo.entity.Comment;
import com.demo.util.JDBCUtils;

/**
 * UserDAO：只针对User的数据库操作
 * 
 * @author david
 *
 */
public class CommentDAO {
	static QueryRunner qr = new QueryRunner();

	// 显示所有评论
	public List<Comment> list() {
		try {
			List<Comment> list = qr.query(
					JDBCUtils.getConnection(), 
					"select * from t_comment",
					new BeanListHandler<Comment>(Comment.class));
			return list;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
